<?php
class km_dt_cabang_model extends MY_Model {
	var $model = 'km_dt_cabang_model';

	function GetJSON($as_pk_master)
	{
		$ls_sql	= "	SELECT	a.shu_dt_id,
					a.shu_id,
					a.shu_dt_class,
					a.shu_dt_amount
					FROM	kst_detail_shu a
					WHERE	a.shu_id = '".$as_pk_master."' 
					ORDER BY ".(post('sort')=='' ? 'a.shu_dt_id' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order')); // ".$as_pk_master."
		return json_encode( $this->paging($ls_sql) );
	}
	
	function GetDetailByID($as_pk_master)
	{
		$ls_sql	= "	SELECT	a.shu_dt_id,
					a.shu_id,
					a.shu_dt_class,
					a.shu_dt_amount
					FROM	kst_detail_shu a
					WHERE	a.shu_id = '".$as_pk_master."' 
					ORDER BY ".(post('sort')=='' ? 'a.shu_dt_id' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order')); // ".$as_pk_master."
		
		$result	= $this->db->query($ls_sql);

		if($result->num_rows() > 0){
			return $result->result_array();
		}else{
			return NULL;
		}
	}
	
	
	// function Add($arr_data){
	// 	$this->db->insert('kst_detail_shu', $arr_data);	
	// }
	
	// function Update($arr_data, $arr_rule){
	// 	$this->db->update('kst_detail_shu', $arr_data, $arr_rule);
	// }
	
	// function GetSingle($as_roleid){
	// 	$result = $this->db->get_where('kst_detail_shu', array('shu_dt_id' => $as_roleid));
	// 	if($result->num_rows() == 1){
	// 		return $result->row_array();
	// 	}else{
	// 		return NULL;
	// 	}
	// }
	
	// function GetSingleView($as_roleid)
	// {
	// 	$result = $this->db->get_where('kst_detail_shu', array('shu_dt_id' => $as_roleid));
	// 	if($result->num_rows() == 1){
	// 		return $result->row_array();
	// 	}else{
	// 		return NULL;
	// 	}
	// }

	// function DeleteSingle($arr_rule)
	// {
	// 	try {
	// 		$this->db->delete('kst_detail_shu', $arr_rule);
	// 		return '';
	// 	} catch(Exception $e) {
	// 		return $e->getMessage();
	// 	}
	// }
}
?>